package com.example.sign;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.TextView;

public class RecordActivity extends AppCompatActivity {
    private TextView tvScoreRecord;
    private static RecordActivity recordActivity=null;
    private int score;

    public RecordActivity(){
        recordActivity=this;
    }
    public static RecordActivity getRecordActivity() {
        return recordActivity;
    }



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_record);
        tvScoreRecord=findViewById(R.id.tv_record);
        scoreRecord();
    }
    final DatabaseHelper dbHelper=new DatabaseHelper(RecordActivity.this);

    public void scoreRecord(){

        SQLiteDatabase db1 = dbHelper.getReadableDatabase();
        Cursor cursor = db1.query("information",null,null,null,null,null,"score desc","1");
        while (cursor.moveToNext()){
            score = cursor.getInt(cursor.getColumnIndex("score"));
        }

        SQLiteDatabase db=dbHelper.getWritableDatabase();
        ContentValues values=new ContentValues();
        values.put("score",MainActivity.getMainActivity().getScore());
        long id =db.insert("information",null,values);

        tvScoreRecord.setText(tvScoreRecord.getText() + "\n" + score);
        db.close();
    }
}
